<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Luat开源项目脚本lib</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>script_LuaTask lib</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>


<h2>Modules</h2>
<ul class="nowrap">
  <li><a href="../modules/aLiYun.html">aLiYun</a></li>
  <li><a href="../modules/aLiYunOta.html">aLiYunOta</a></li>
  <li><a href="../modules/agps.html">agps</a></li>
  <li><a href="../modules/agpsHxxt.html">agpsHxxt</a></li>
  <li><a href="../modules/agpsZkw.html">agpsZkw</a></li>
  <li><a href="../modules/audio.html">audio</a></li>
  <li><a href="../modules/cc.html">cc</a></li>
  <li><a href="../modules/clib.html">clib</a></li>
  <li><a href="../modules/common.html">common</a></li>
  <li><a href="../modules/console.html">console</a></li>
  <li><a href="../modules/errDump.html">errDump</a></li>
  <li><a href="../modules/ftp.html">ftp</a></li>
  <li><a href="../modules/gps.html">gps</a></li>
  <li><a href="../modules/gpsHxxt.html">gpsHxxt</a></li>
  <li><a href="../modules/gpsZkw.html">gpsZkw</a></li>
  <li><a href="../modules/http.html">http</a></li>
  <li><a href="../modules/lbsLoc.html">lbsLoc</a></li>
  <li><a href="../modules/led.html">led</a></li>
  <li><a href="../modules/link.html">link</a></li>
  <li><a href="../modules/log.html">log</a></li>
  <li><a href="../modules/misc.html">misc</a></li>
  <li><a href="../modules/mqtt.html">mqtt</a></li>
  <li><a href="../modules/net.html">net</a></li>
  <li><a href="../modules/netLed.html">netLed</a></li>
  <li><a href="../modules/ntp.html">ntp</a></li>
  <li><a href="../modules/nvm.html">nvm</a></li>
  <li><a href="../modules/patch.html">patch</a></li>
  <li><a href="../modules/pb.html">pb</a></li>
  <li><strong>pins</strong></li>
  <li><a href="../modules/pm.html">pm</a></li>
  <li><a href="../modules/powerKey.html">powerKey</a></li>
  <li><a href="../modules/record.html">record</a></li>
  <li><a href="../modules/ril.html">ril</a></li>
  <li><a href="../modules/scanCode.html">scanCode</a></li>
  <li><a href="../modules/sim.html">sim</a></li>
  <li><a href="../modules/sms.html">sms</a></li>
  <li><a href="../modules/socket.html">socket</a></li>
  <li><a href="../modules/sys.html">sys</a></li>
  <li><a href="../modules/uiWin.html">uiWin</a></li>
  <li><a href="../modules/update.html">update</a></li>
  <li><a href="../modules/utils.html">utils</a></li>
  <li><a href="../modules/websocket.html">websocket</a></li>
  <li><a href="../modules/wifiScan.html">wifiScan</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>pins</code></h1>
<p>模块功能：GPIO 功能配置，包括输入输出IO和上升下降沿中断IO</p>
<p></p>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: openLuat</li>
        <li><strong>Release</strong>: 2017.09.23 11:34</li>
        <li><strong>License</strong>: MIT</li>
        <li><strong>Author</strong>: openLuat</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#setup">
    setup (pin, val, pull)
    </a></td>
	<td class="summary">配置GPIO模式</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#close">
    close (pin)
    </a></td>
	<td class="summary">关闭GPIO模式</td>
	</tr>
</table>

<br/>
<br/>


    <h2 class="section-header "><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "setup"></a>
    <strong  style="color: red;">
    setup (pin, val, pull)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">配置GPIO模式</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">pin</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">GPIO ID
 GPIO 0到GPIO 31表示为pio.P0_0到pio.P0_31
 GPIO 32到GPIO XX表示为pio.P1_0到pio.P1_(XX-32)，例如GPIO33 表示为pio.P1_1
 GPIO 64到GPIO XX表示为pio.P2_0到pio.P2_(XX-64)，例如GPIO65 表示为pio.P2_1</pre>
        </li>
        <li><span class="parameter">val</span>
        <pre class="example">number、nil或者function类型
 配置为输出模式时，为number类型，表示默认电平，0是低电平，1是高电平
 配置为输入模式时，为nil
 配置为中断模式时，为function类型，表示中断处理函数</pre>
        </li>
        <li><span class="parameter">pull</span>
        <pre class="example"> number, pio.PULLUP：上拉模式 。pio.PULLDOWN：下拉模式。pio.NOPULL：高阻态
 如果没有设置此参数，默认的上下拉参考模块的硬件设计说明书</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example"> function
 配置为输出模式时，返回的函数，可以设置IO的电平
 配置为输入或者中断模式时，返回的函数，可以实时获取IO的电平</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">setOutputFnc = pins.setup(pio.P1_1,<span class="number">0</span>)，配置GPIO <span class="number">33</span>，输出模式，默认输出低电平；
执行setOutputFnc(<span class="number">0</span>)可输出低电平，执行setOutputFnc(<span class="number">1</span>)可输出高电平</pre></il>
        <li><pre class="example">getInputFnc = pins.setup(pio.P1_1,intFnc)，配置GPIO33，中断模式
产生中断时自动调用intFnc(msg)函数：上升沿中断时：msg为cpu.INT_GPIO_POSEDGE；下降沿中断时：msg为cpu.INT_GPIO_NEGEDGE
执行getInputFnc()即可获得当前电平；如果是低电平，getInputFnc()返回<span class="number">0</span>；如果是高电平，getInputFnc()返回<span class="number">1</span></pre></il>
        <li><pre class="example">getInputFnc = pins.setup(pio.P1_1),配置GPIO33，输入模式
执行getInputFnc()即可获得当前电平；如果是低电平，getInputFnc()返回<span class="number">0</span>；如果是高电平，getInputFnc()返回<span class="number">1</span></pre></il>
        <li><pre class="example">有些GPIO需要打开对应的ldo电压域之后，才能正常配置工作，电压域和对应的GPIO关系如下
pmd.ldoset(x,pmd.LDO_VSIM1) <span class="comment">-- GPIO 29、30、31
</span>pmd.ldoset(x,pmd.LDO_VLCD) <span class="comment">-- GPIO 0、1、2、3、4
</span>pmd.ldoset(x,pmd.LDO_VMMC) <span class="comment">-- GPIO 24、25、26、27、28
</span>x=<span class="number">0</span>时：关闭LDO
x=<span class="number">1</span>时：LDO输出<span class="number">1.716</span>V
x=<span class="number">2</span>时：LDO输出<span class="number">1.828</span>V
x=<span class="number">3</span>时：LDO输出<span class="number">1.939</span>V
x=<span class="number">4</span>时：LDO输出<span class="number">2.051</span>V
x=<span class="number">5</span>时：LDO输出<span class="number">2.162</span>V
x=<span class="number">6</span>时：LDO输出<span class="number">2.271</span>V
x=<span class="number">7</span>时：LDO输出<span class="number">2.375</span>V
x=<span class="number">8</span>时：LDO输出<span class="number">2.493</span>V
x=<span class="number">9</span>时：LDO输出<span class="number">2.607</span>V
x=<span class="number">10</span>时：LDO输出<span class="number">2.719</span>V
x=<span class="number">11</span>时：LDO输出<span class="number">2.831</span>V
x=<span class="number">12</span>时：LDO输出<span class="number">2.942</span>V
x=<span class="number">13</span>时：LDO输出<span class="number">3.054</span>V
x=<span class="number">14</span>时：LDO输出<span class="number">3.165</span>V
x=<span class="number">15</span>时：LDO输出<span class="number">3.177</span>V
除了上面列举出的GPIO外，其余的GPIO不需要打开特定的电压域，可以直接配置工作</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "close"></a>
    <strong  style="color: red;">
    close (pin)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">关闭GPIO模式</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">pin</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">GPIO ID
<p> GPIO 0到GPIO 31表示为pio.P0_0到pio.P0_31
<p> GPIO 32到GPIO XX表示为pio.P1_0到pio.P1_(XX-32)，例如GPIO33 表示为pio.P1_1</pre>
        </li>
    </ul>




    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">pins.close(pio.P1_1)，关闭GPIO33</pre></il>
    </ul>

</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-08-02 13:53:19 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

